<template>
  <div>
    <Form label-position="right" :label-width="400">
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">姓名：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Input v-model="personinfo.name" disabled></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">证件号码：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Input v-model="personinfo.cardno" disabled></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">证件类型：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Select v-model="params.idcard_type" style="width:218px" filterable>
            <Option value="01">公民身份号码</Option>
            <Option value="08">外国人护照</Option>
            <Option value="11">光荣证</Option>
            <Option value="12">残疾证</Option>
            <Option value="13">烈士证</Option>
            <Option value="14">优抚证</Option>
            <Option value="15">低保证</Option>
            <Option value="16">低保边缘证</Option>
          </Select>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">户口性质：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Select v-model="params.resident" style="width:218px" filterable>
            <Option value="10">非农业户口(城镇)</Option>
            <Option value="20">农业户口(农村)</Option>
            <Option value="30">港澳台</Option>
            <Option value="40">外籍</Option>
            <Option value="50">居民户口</Option>
          </Select>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">民族：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Select v-model="params.nation" style="width:218px" filterable>
            <Option v-for="item in mzList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">联系电话：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Input v-model="params.mobile" ></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">居住地址：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Input v-model="params.present_address" ></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">邮政编码：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Input v-model="params.postal" ></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">银行类别：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Select v-model="params.bank_type" style="width:218px">
            <Option value="103">农业银行</Option>
            <Option value="104">农村信用合作社</Option>
          </Select>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="7" class="ivu-form-item-label">银行帐号：</Col>
        <Col span="12" class="ivu-form-item-content">
          <Input v-model="params.bank_cardno" ></Input>
        </Col>
      </Row>
    </Form>
  </div>
</template>

<script>
import itemdata from '../itemdata'

export default {
  name: 'insuredRegisterForm',
  props: {
    params: Object,
    personinfo: Object,
    state: Number,
    flag: Boolean,
    setnation: String
  },
  data () {
    return {
      mzList: itemdata.nationList,
      errorTitle: '错误'
    }
  },
  methods: {
    test () {
      if (this.params.resident === '' || this.params.resident === undefined) {
        const content = '<p>请选择户口性质</p>'
        this.$Modal.error({
          title: this.errorTitle,
          content: content
        })
        return
      }
      if (this.params.nation === '' || this.params.nation === undefined) {
        const content = '<p>请选择民族</p>'
        this.$Modal.error({
          title: this.errorTitle,
          content: content
        })
        return
      }
      if (this.params.bank_type === '' || this.params.bank_type === undefined) {
        const content = '<p>请选择银行类别</p>'
        this.$Modal.error({
          title: this.errorTitle,
          content: content
        })
        return
      }
      if (this.params.bank_cardno === '' || this.params.bank_cardno === undefined) {
        const content = '<p>请填写银行账号</p>'
        this.$Modal.error({
          title: this.errorTitle,
          content: content
        })
        return
      }
      this.$emit('saveSuccess', this.flag)
    }
  },
  watch: {
    state (num) {
      if (!this.params.cardno) {
        this.params.sex = this.personinfo.sex === '男' ? '1' : '2'
        this.params.idcard_type = '01'
        this.params.mobile = this.personinfo.mobile
        this.params.present_address = this.personinfo.present_address
        this.params.domicile_address = this.personinfo.domicile_address || ''
      }
    },
    setnation (nation) {
      if (nation && !this.params.nation) {
        for (let item in this.mzList) {
          if (nation === this.mzList[item].label) {
            this.params.nation = this.mzList[item].value
            return
          }
        }
      }
    }
  },
  mounted () {
  }
}
</script>

<style scoped>
</style>
